home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / drgnsmth.cpt / Dragonsmith 1.1 / Template files / DPlainTmpl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-12  |  3.8 KB  |  87 lines

  1. /*
  2.     DPlainTmpl.c
  3.     
  4.     Template for a very simple auto-quit Dragon sub-species
  5.     
  6.     Don't use this template file if your dragon has menus or any preferences (not counting those used by the Dragon class)
  7.     You can get rid of the auto-quit behavior of this dragon by changing the constructor method AND the 'DrPr' 128 resource
  8.         in your renamed copy of PlainTmpl.╣.rsrc (see below for more details)
  9.     Please note that there is a null string in the 'STR ' 128 resource in PlainTmpl.╣.rsrc file, so a dragon based on this
  10.         template won't find or create a preferences file ╤ why would it need one, if there's no interface for the user to use
  11.         to change preferences settings?
  12.     
  13.     To base a simple dragon (let's call it "Smaug") on the code in this file ╤
  14.     
  15.     1.    Make a copy of this file and rename it "DSmaug.c"
  16.     2.    Make a copy of the file "Template.╣" and name it "Smaug.╣"
  17.     3.    Add DSmaug.c to the Smaug.╣ project
  18.     4.    Change your project "creator" value to your dragon's signature
  19.     5.    Make a copy of the file "PlainTmpl.╣.rsrc" and name it "Smaug.╣.rsrc"
  20.     6.    Change all instances in this file of the string "PrefsTmpl" to "Smaug"
  21.     7.    Move Smaug.╣.rsrc up so it's in the same folder as Smaug.╣
  22.     8.    Make the following changes in Smaug.╣.rsrc ╤
  23.         ª Use ResEdit 2.1's 'BNDL' editor to change your dragon's signature and add an 'FREF' resource for each document
  24.             type the user can drag-and-drop on your dragon ('****' is all files, 'fold' is folders, and 'disk' is volumes)
  25.         ª Use ResEdit's icon family editor to change your dragon's icon ╤ a boring icon is provided for you to fiddle with
  26.         ª Change the values in 'DrPr' 128 (resolveAliases, dirDepthLimit, etc.), if you wish ╤ do NOT delete this resource
  27.         ª Edit the 'TEXT'/'styl' 128 resources ╤ they provide the Finder's help text for your dragon's icon (or remove these
  28.             two resources, as well as 'hfdr' ╨5696, if you'd rather not have this feature)
  29.         ª Change the value in 'MoMa' 128 if your dragon needs to call MoreMasters when it starts up
  30.         ª Edit the two 'vers' resources
  31.     9.    Rewrite the method DSmaug::ProcessFile (or ProcessDirectory, or both) so your dragon actually does something
  32.     10.    Add other code as necessary
  33.  
  34.     Created    28 Sep 1992    Class declaration, ProcessFile, ProcessDirectory
  35.     Modified    
  36.     
  37. */
  38.                                     
  39. #include    "Dragon.h"
  40.  
  41. class DPlainTmpl: public Dragon {
  42.     
  43.     protected:
  44.         // Add instance variables here
  45.  
  46.     public:
  47.                         DPlainTmpl (void);
  48.         virtual void        ProcessFile (void);
  49.         virtual void        ProcessDirectory (void);
  50.     
  51.     protected:
  52.         // Add protected methods here
  53. };
  54.  
  55. Dragon *CreateGDragon (void)
  56. {
  57.     // This is a function, not a method.  It's declared in Dragon.h and is NOT defined in Dragon.c
  58.     
  59.     return (Dragon *) new DPlainTmpl;
  60. }
  61.  
  62. DPlainTmpl::DPlainTmpl (void)
  63. {
  64.     // You should initialize any added instance variables here ╤ this method will be called whenever an object of
  65.     //    this class is created, immediately after Dragon::Dragon
  66.     
  67.     autoQuit = TRUE;        // This will be overridden by whatever value for autoQuit is specified in the 'DrPr' 128 resource in
  68.                         //    your project resource file ╤ so just removing this line won't necessarily be enough to keep
  69.                         //    it from auto-quitting.  The file "PlainTmpl.╣.rsrc" has a 'DrPr' 128 that sets autoQuit = TRUE
  70. }
  71.  
  72. void DPlainTmpl::ProcessFile (void)
  73. {
  74.     // This is the heart of your dragon.  You can open the file, change its file attributes, or whatever ╔
  75.     // Simple changes can be simplified by using the macros defined in Dragon.h (curDocIsFile, curFileType, etc.)
  76.     
  77.     // Note that this method will not be called if you open a preferences file created by this dragon ╤ that's
  78.     //    all taken care of for you by Dragon (see ProcessOwnedFile)
  79. }
  80.  
  81. void DPlainTmpl::ProcessDirectory (void)
  82. {
  83.     // Use this method to process folders and disks instead of just ignoring them or looking inside them for files
  84.     // If you don't use this method, you can just delete it (and its declaration above) ╤ I put it here merely for convenience
  85. }
  86.  
  87.